package com.woniuxy.rabbitmqspringboot.direct;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author zhangyong
 * @Date 2021/8/12 0012下午 12:00
 */
@Component
public class DirectProductor {
    @Resource
    private AmqpTemplate amqpTemplate;

    public void send(String data){
        //将消息发送到交换机
        //参数1：交换机的名字
        //参数2：路由
        amqpTemplate.convertAndSend("direct_exchange","news",data);
    }

}
